﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;

namespace MINERP.COM
{
    public class WriteLogForCheck
    {

        static string filePath = Environment.CurrentDirectory + @"\AccessDBRecords.log";

        public static bool CreateLogFile()
        {
            try
            {
                if (!File.Exists(filePath))
                {
                    File.Create(filePath);
                }
                return true;
            }
            catch (Exception ex)
            {
                return false;
                throw ex;
            }
        }

        public static int WriteLogFile(StringBuilder sb)
        {
            int result = 0;
            StreamWriter sw = null;

            using (sw = new StreamWriter(filePath, true))
            {

                try
                {
                    sw.WriteLine(sb.ToString());
                    sw.Close();
                    return result;
                }
                catch (Exception ex)
                {
                    throw ex;
                }
                finally
                {
                    sw.Close();
                }
            }



        }
        public static int WriteLogFile(string strMsg)
        {
            int result = 0;
            StreamWriter sw = null;
            using (sw = new StreamWriter(filePath, true))
            {
                try
                {
                    sw.WriteLine(strMsg);
                    sw.Close();
                    return result;
                }
                catch (Exception ex)
                {
                    throw ex;
                }
                finally
                {
                    sw.Close();
                }
            }
        }
    }
}
